package com.sky.service.impl.user;

import com.sky.result.Result;
import com.sky.service.user.ShoppingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ShopServiceImpl implements ShoppingService {
    @Autowired
    private  RedisTemplate redisTemplate;


    //操作redis 操作String类型的Operations对象
    @Override
    public Result<Object> setShopStatus(Integer status) {
        // 设置营业状态
        redisTemplate.opsForValue().set("shopStatus", status);

        return Result.success();
    }

    @Override
    public Result<Object> getShopStatus() {
        Integer  status = (Integer)redisTemplate.opsForValue().get("shopStatus");
        status = status == null ? 0 : status;
        return Result.success(status);

    }
}
